﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
using System.Data.SqlClient;

namespace Tayninh2011
{
    public partial class RootForm : Form
    {
        protected static IWorkspaceEdit _sdeWorkspace=null;
        protected static IFeatureWorkspace _featureWorkspace=null;
        protected static IWorkspace _mdbWorkspace=null;
        protected static string _sdeEnvironment = String.Empty;
        protected static string[,] _arrUserInfo=null;
        protected static string _strNameTableThua = "tn_thua";
        protected static string _strNameTableDuong = "tn_duong";
        protected static string _strNameTableHem = "tn_hem";
        protected static string _strNameTableThuaGiadat = "thua_giadat";
        protected static string _strNameTableDuongGiadat = "duong_giadat";
        protected static string _strNameTableHemGiadat = "hem_giadat";
        //protected static string _strNameTableThuaGiadat = "thua_giadat";
        protected static string _strServerName = String.Empty;
        protected static string _strPathTempFolder = "C:/tayninh/temp";
        protected static string _strNameTempMdbFile = "tempmdb";
        protected static string _strXmlUserFileName = "userInfo";
        protected static string _strXmlLayersFileName = "layers";
        protected static string _strVersion = "sde.DEFAULT";
        protected static string _strVersionTail = "sde";
        protected static List<List<string>> _lstLayersClf = new List<List<string>>();
        protected static List<string[]> _lstLayers = new List<string[]>();
        protected static List<string[]> _lstDefaultLayers = new List<string[]>();
        protected static SqlConnection _sqlConnection=null;
        protected static int modeApp = TnModeApp.SEE_ONLY;
        private ITnUtilitiesFile fileUtil = new TnUtilities();
        private static TnCalculatorFactory calcFactory = TnCalculatorFactory.CallMe;

        private static TnToolsCalculator calcTool3010 = null;
        private static TnToolsCalculator calcTool3020 = null;
        private static TnToolsCalculator calcTool31xx32xx = null;
        protected static Boolean IsSeeOnly = true;

        public RootForm()
        {
            InitializeComponent();
        }

        public static TnToolsCalculator CalcTool3010
        {
            get { return RootForm.calcTool3010; }
            set { RootForm.calcTool3010 = value; }
        }

        public static TnToolsCalculator CalcTool3020
        {
            get { return RootForm.calcTool3020; }
            set { RootForm.calcTool3020 = value; }
        }

        public static TnToolsCalculator CalcTool31xx32xx
        {
            get { return RootForm.calcTool31xx32xx; }
            set { RootForm.calcTool31xx32xx = value; }
        }

        public static TnCalculatorFactory CalcFactory
        {
            get { return calcFactory; }
            //set { RootForm.calcFactory = value; }
        }

        public static string SdeEnvironment
        {
            set { _sdeEnvironment = value; }
            get { return _sdeEnvironment; }
        }

        public static IWorkspaceEdit SdeWorkspace
        {
            get { return _sdeWorkspace; }
            set { _sdeWorkspace = value; }
        }

        public static SqlConnection Sqlconnection
        {
            get { return _sqlConnection; }
        }

        public static string[,] UserInfo
        {
            set { _arrUserInfo = value; }
            get { return _arrUserInfo; }
        }

        public static string NameThua
        {
            get { return _strNameTableThua; }
            set { _strNameTableThua = value; }
        }

        public static string NameDuong
        {
            get { return _strNameTableDuong; }
            set { _strNameTableDuong = value; }
        }
        public static string NameHem
        {
            get { return _strNameTableHem; }
            set { _strNameTableHem = value; }
        }
        
        public static string[] GetLayers
        {
            get
            {
                return new string[]{_strNameTableThua,_strNameTableDuong,_strNameTableHem};   
            }

        }

        //private void initLstLayers()
        //{
        //    _lstDefaultLayers.Add(new string[] { "thua", _strNameTableThua });
        //    _lstDefaultLayers.Add(new string[] { "duong", _strNameTableDuong });
        //    _lstDefaultLayers.Add(new string[] { "hem", _strNameTableHem });
        //    _lstDefaultLayers.Add(new string[] { "thua_giadat", _strNameTableThuaGiadat });
        //    _lstLayers = _lstDefaultLayers;
        //}

        //private void initLstLayersClf()
        //{
        //    if (System.IO.File.Exists(_strXmlLayersFileName + ".xml"))
        //    {
        //        RootForm._lstLayersClf = fileUtil.ReadLayersFormXmlFile(_strXmlLayersFileName, "");
        //    }
        //    else
        //    {
        //        fileUtil.CreateXmlFile("sde", _lstDefaultLayers, _strXmlLayersFileName, "");
        //        RootForm._lstLayersClf = fileUtil.ReadLayersFormXmlFile(_strXmlLayersFileName, "");
        //    }
        //}
    }
}
